package com.itluma.isWOak.exception;

import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author MS
 * @date 2021/4/12 19:24
 **/

@Component
public class MyExResolver implements HandlerExceptionResolver{

    private Logger log = LoggerFactory.getLogger (MyExResolver.class);
    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e){
        log.info ("进入异常处理器: "+ e.getClass ().getName () + e.getMessage ());
        ModelAndView mv = new ModelAndView ();
        String error = "";

        if (e.getClass ().getName () != null) {
            mv.setViewName ("error/error_500");
        }
        mv.addObject ("error", error);
        return mv;
    }
}